//
//  GCMNoticeTableViewCell.m
//  GeeCityManager
//
//  Created by 聚城科技 on 16/3/15.
//  Copyright © 2016年 聚城科技. All rights reserved.
//

#import "GCMNoticeTableViewCell.h"

@implementation GCMNoticeTableViewCell{

    UIView * _bgView;
    UIImageView *_titleImageV;
    UIImageView *_rightImageV;
    UILabel *_titleLabel;
    UILabel *_contentLabel;
    UILabel *_dataLabel;
    UIWebView *_webView;
}
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    if ([super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self createUI];
    }
    return self;
}

-(void)createUI{
    
    _bgView = [[UIImageView alloc]init];
    _bgView.frame =CGRectMake(10, 10,SCREEN_WIDTH - 20, 100);
    _bgView.backgroundColor = [UIColor whiteColor];
    [self.contentView addSubview:_bgView];
    
    _titleImageV = [[UIImageView alloc]init];
    _titleImageV.frame = CGRectMake(10, 7, 20, 18) ;
    _titleImageV.backgroundColor = [UIColor colorWithRed:0.98 green:0.98 blue:0.98 alpha:1.00];
    [_bgView addSubview:_titleImageV];
    
    
    
    _titleLabel = [[UILabel alloc]init];
    _titleLabel.frame = CGRectMake(35,5,SCREEN_WIDTH, 20);
    _titleLabel.font = [UIFont systemFontOfSize:15];
//    _titleLabel.textColor = [UIColor lightGrayColor];
    _titleLabel.textAlignment = NSTextAlignmentLeft;
    [_bgView addSubview:_titleLabel];
    
    _contentLabel = [[UILabel alloc]init];
    _contentLabel.frame = CGRectMake(20 ,30 , _bgView.bounds.size.width - 40, 30);
    _contentLabel.font = [UIFont systemFontOfSize:16];
    _contentLabel.textColor = [UIColor colorWithRed:0.58 green:0.65 blue:0.65 alpha:1.00];
    _contentLabel.textAlignment = NSTextAlignmentLeft;
    [_bgView addSubview:_contentLabel];
    
    _rightImageV = [[UIImageView alloc]init];
    _rightImageV.frame = CGRectMake(_bgView.bounds.size.width - 45, 35, 30, 30) ;
    [_rightImageV setImage:[UIImage imageNamed:@"common_ic_arrow_right"]];
    [_bgView addSubview:_rightImageV];
    
    _dataLabel = [[UILabel alloc]init];
    _dataLabel.frame = CGRectMake(0,_bgView.bounds.size.height - 25, _bgView.bounds.size.width - 5,25 );
    _dataLabel.font = [UIFont systemFontOfSize:14];
    _dataLabel.textAlignment = NSTextAlignmentRight;
    _dataLabel.textColor = [UIColor colorWithRed:0.91 green:.30 blue:.24 alpha:1];
    [_bgView addSubview:_dataLabel];
    
}

-(void)setNoticeModel:(GCMNoticeListModel *)noticeModel{
    
    _noticeModel = noticeModel;
    _titleLabel.text = _noticeModel.title;
    NSLog(@"%@",_noticeModel.title);
    NSString *conStr = [[NSString alloc]init];
    conStr = [_noticeModel.content  stringByReplacingOccurrencesOfString:@"&nbsp;" withString:@""];
       _contentLabel.text = conStr;
    //    _isReadLabel.text = [NSString stringWithFormat:@"%d",noModel.isRead];
    if ([_noticeModel.isRead isEqualToString:@"1"]) {
        _titleImageV.image = [UIImage imageNamed:@"notice_ic_read"];
    }else{
    
        _titleImageV.image = [UIImage imageNamed:@"notice_ic_unread"];
    }
    
    _dataLabel.text = [GCMNoticeTableViewCell getDateFromString:_noticeModel.pubTime];

}

+ (NSString *)getDateFromString:(NSString *)dateStr
{
    NSArray *array = [dateStr componentsSeparatedByString:@" "];
    NSString *date = [array objectAtIndex:0];
    return date;
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
